#coding:utf-8
from django import forms
from models import *

class LoginForm(forms.Form):
    username = forms.CharField(required=True,max_length=64,label=u"用户名")
    password = forms.CharField(required=True, max_length=64,label=u"密    码",widget=forms.PasswordInput)

         
class RegisterForm(forms.Form):
    username = forms.CharField(required=True,max_length=64,label=u"用户名称",help_text=u"中英文均可，友好一点，酷一点")
    email = forms.EmailField(required=True,label=u"你的电子邮箱",help_text=u"激活帐号,找回密码会用到它,尽量填写正确")
    password = forms.CharField(required=True,min_length=6,max_length=64,label=u"你的密码",widget=forms.PasswordInput,help_text=u"最少6个字符，请使用英文字母（区分大小写）、符号或数字。 ")
    vcode = forms.CharField(required=True,label=u"验证码",help_text=u"请输入图中的验证码")
    
class GroupForm(forms.Form):
    name = forms.CharField(
        required=True,max_length=32,
        widget=forms.TextInput(attrs={"size":"40"}),
        label=u"圈子名称",help_text=u"中英文均可,最多16个汉字"
    )
    privacy = forms.ChoiceField(
        required=True,label=u"圈子类型",
        choices=(("default",u"公开圈子"),("audit",u"加入需要审核"),("private",u"私有圈子加入需邀请")),
        widget=forms.Select
    )
    summary = forms.CharField(
        required=True,max_length=1024,
        label=u"圈子描述",help_text=u"简要描述一下小组，最多512个汉字",
        widget=forms.Textarea(attrs={"style":"width:360px;","class":"corner"})
    )
    categorys = forms.CharField(
        required=True,label=u"圈子标签",
        widget=forms.TextInput(attrs={"size":"60"}) ,
        help_text=u"每个圈子可以设置5个标签,用逗号分开"
    ) 
    group_type = forms.MultipleChoiceField(
        label=u"可选标签",
        choices=(("all",u"综合"),("device",u"玩机交流"),("app",u"软件应用"),("develop",u"开发者")),
        widget=forms.CheckboxSelectMultiple
    )   

         
class DeviceForm(forms.ModelForm):
    fmtags = forms.CharField(
        required=True,label=u"手机标签",
        widget=forms.TextInput(attrs={"size":"60"}) ,
        help_text=u"每个手机可以设置多个标签,用逗号分开"
    )        
    pretags = forms.MultipleChoiceField(
        label=u"可选标签",
        choices=(("android",u"android"),
                 ("symbian",u"symbian"),
                 ("iphone",u"iphone"),
                 ("webos",u"webos"),
                 ("blackberry",u"blackberry"),
                 ("other",u"other")),
        widget=forms.CheckboxSelectMultiple
    )    
    group = forms.ModelChoiceField(queryset=Group.objects.filter(gtype=u"system"))       
    class Meta:
       model = Device
       fields = ('name',"pubdate", 'company',"company_url","image","summary","group")

        
class AppForm(forms.ModelForm):
    fmtags = forms.CharField(
        required=True,label=u"手机标签",
        widget=forms.TextInput(attrs={"size":"60"}) ,
        help_text=u"每个手机可以设置多个标签,用逗号分开"
    ) 
    pretags = forms.MultipleChoiceField(
        label=u"可选标签",
        choices=(("android",u"android"),
                 ("symbian",u"symbian"),
                 ("iphone",u"iphone"),
                 ("webos",u"webos"),
                 ("blackberry",u"blackberry"),
                 ("j2me",u"j2me"),
                 ("other",u"其它")),
        widget=forms.CheckboxSelectMultiple
    )           
    class Meta:
       model = App
       fields = ('name',"version","app_url","auther","auther_url","pubdate","image","summary")            
        
        
        
        
        
        
        
        
        
